#! /bin/bash
export LANG=zh_CN.UTF-8


--分区
SET hive.exec.dynamic.partition=true;
SET hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.max.dynamic.partitions.pernode=10000;
set hive.exec.max.dynamic.partitions=100000;
set hive.exec.max.created.files=150000;

----------------------插入dws_clue数据-----------------------
truncate table edu_dws.customer_clue;
insert into edu_dws.customer_clue partition (dt )
select
    fcc.id,
    fcc.customer_relationship_id,
    fcc.clue_state,
    fcr.create_date_time,
    fcr.deleted,
    fcr.customer_id,
    fcr.origin_type,
    fcr.itcast_school_id,
    fcr.itcast_subject_id,
    fcr.origin_channel,
    fcr.payment_state,
    fcr.payment_time,
    fcr.creator,
    dca.customer_relationship_first_id,
    dca.appeal_status,
    dca.dt
from edu_dwd.fact_customer_clue fcc
left join edu_dwd.fact_customer_relationship fcr on fcr.first_id=fcc.customer_relationship_id
left join edu_dwd.dim_customer_appeal dca on fcc.customer_relationship_id=dca.customer_relationship_first_id;


----------------------------------插入dws_customer_relationship--------------------------------
truncate table edu_dws.customer_relationship;
insert into edu_dws.customer_relationship partition (dt)
select
    fcr.id,
    fcr.create_date_time,
    fc
    r.deleted,
    fcr.customer_id,
    fcr.origin_type,
    fcr.itcast_school_id,
    fcr.itcast_subject_id,
    fcr.origin_channel,
    fcr.payment_state,
    fcr.payment_time,
    fcr.creator,
    fcc.id as clue_id,
    fcc.customer_relationship_id,
    fcc.clue_state,
    dc.id as stu_id,
    dc.area,
    dis.id as subject_id,
    dis.id as subject_name,
    disc.id as school_id,
    disc.name as school_name,
    de.id as employee_id,
    de.tdepart_id,
    dsd.id as dep_id,
    dsd.name as dep_name,
    fcr.dt
from edu_dwd.fact_customer_relationship fcr
left join edu_dwd.fact_customer_clue fcc on fcr.first_id=fcc.customer_relationship_id
left join edu_dwd.dim_customer dc on dc.id=fcr.customer_id
left join edu_dwd.dim_itcast_subject dis on dis.id=fcr.itcast_subject_id
left join edu_dwd.dim_itcast_school disc on disc.id=fcr.itcast_school_id
left join edu_dwd.dim_employee de on de.id=fcr.creator
left join edu_dwd.dim_scrm_department dsd on dsd.id=de.tdepart_id;
















